<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>
        投诉建议审核
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/statics/css/main.css" media="all">
    <script type="text/javascript" src="${pageContext.request.contextPath }/statics/lib/loading/okLoading.js"></script>
</head>
<style>
    .imgs {
        display: none;
    }
</style>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>服务管理</cite></a>
              <a><cite>投诉建议</cite></a>
                <a><cite>审核</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form layui-form-pane" method="post" id="add"
          enctype="multipart/form-data">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" value="${param.id}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'></span>内容
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="myContent" autocomplete="off" placeholder="内容"
                                   class="layui-input" value="" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'></span>所属区域
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="myarea" autocomplete="off" placeholder="所属区域"
                                   class="layui-input" value="" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-form-item imgs" id="imgshow">
                        <label class="layui-form-label">缩略图展示</label>
                        <img src="" id="pimages" name="pimages"
                             style="width: 400px;height: 200px;"/>
                        <input id="avatar" name="filePath" type="hidden" value="">
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'></span>投诉时间
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="createDate" autocomplete="off" placeholder="开发商名称"
                                   class="layui-input" value="" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>审核状态
                        </label>
                        <div class="layui-input-block">
                            <input type="radio" name="status" value="1" title="待受理">
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                                    class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <div>待受理</div>
                            </div>
                            <input type="radio" name="status" value="2" title="已受理">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>已受理</div>
                            </div>
                            <input type="radio" name="status" value="3" title="受理未通过">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>已受理</div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class="x-red">*</span>审核备注
                        </label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" name="remark" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item" align="center">
                        <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="${pageContext.request.contextPath }/statics/lib/layui/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/statics/js/x-layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/statics/js/jquery.min.js" charset="utf-8"></script>
<script>

    if ($("input[name='id']").val() != "") {    //根据id查询数据
        var id = $("input[name='id']").val()
        $.get("/complain/" + id, function (data) {
            $("input[name='myContent']").val(data.data.myContent)
            var area;
            if (data.data.buildingNumber != null) {
                area = data.data.myArea + "一" + data.data.buildingNumber + "栋一" + data.data.roomNumber;
            } else {
                area = data.data.myArea
            }
            $("input[name='myarea']").val(area)
            $("input[name='createDate']").val(data.data.createDate)
            if (data.data.imageUrl != "" && data.data.imageUrl != null) {
                $("#pimages").attr('src', data.data.imageUrl);
                $("#avatar").val(data.data.imageUrl);
                $(".imgs").show();
            }
            if (data.data.status == 1) {
                $(':radio:nth-of-type(1)').attr('checked', 'true');
            }
            if (data.data.status == 2) {
                $(':radio:nth-of-type(2)').attr('checked', 'true');
            }
            if (data.data.status == 3) {
                $(':radio:nth-of-type(3)').attr('checked', 'true');
            }
            $("textarea[name='remark']").val(data.data.remark)
        })
    }


    layui.use(['element', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);
        form.render();
        //以上模块根据需要引入


        //监听提交
        form.on('submit(add)', function (data) {
            var data = data.field;
            $.ajax({
                type: "put",
                url: "/complain/update",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.data == true) {
                        layer.msg(data.msg, {icon: 6, time: 2000}, function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                        return false;
                    }
                    else {
                        layer.msg(data.info, {icon: 5, time: 2000});
                        return false;
                    }
                }
            });
        });
    })
</script>

</body>
</html>